package com.example.qdindex.biz.impl;

import com.example.qdindex.biz.GouWuCheBiz;
import com.example.qdindex.mapper.GouWuCheMapper;
import org.example.bean.GouWuCheInfo;
import org.example.bean.TushuInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class GouWuCheBizImpl implements GouWuCheBiz {
    @Autowired
    private GouWuCheMapper gwcm;
    @Override
    public List<TushuInfo> findGWCByKeHuId(int kehuid) {
        List<GouWuCheInfo> list = gwcm.findGWCByKeHuId(kehuid);
        List<TushuInfo> TuShuList = new ArrayList<>();
        for (GouWuCheInfo s:list){
            TushuInfo tu = gwcm.findTuShuByTuShuId(s.getTuShuId());
            tu.setShuliag(s.getShuliang());
            TuShuList.add(tu);
        }
        return TuShuList;
    }

    @Override
    public void updateGWCShuliang(int shuliang, int tuShuId) {
        gwcm.updateGWCShuliang(shuliang,tuShuId);
    }
}
